pub fn new_count_distinct(input_str: &str) -> usize {
    if input_str.is_empty() {
        return 0;
    }

    // 创建哈希表，初始容量设置为输入长度的两倍以减少冲突
    let initial_capacity = input_str.split(',').count() * 2;
    let mut hash_set = HashSet::new(initial_capacity);

    // 遍历并插入元素
    for element in input_str.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()) {
        hash_set.insert(element);
    }

    hash_set.size
}

// 定义哈希表的节点结构
struct Entry<'a> {
    key:  &'a str,
    // 使用链表处理冲突
    next: Option<Box<Entry<'a>>>,
}

// 哈希表
struct HashSet<'a> {
    buckets: Vec<Option<Box<Entry<'a>>>>,
    size: usize,
    capacity: usize,
}

impl<'a> HashSet<'a> {
    // 创建新的哈希表
    fn new(capacity: usize) -> Self {
        HashSet {
            buckets: (0..capacity).map(|_| None).collect(),
            size: 0,
            capacity,
        }
    }

    // 计算哈希值
    fn hash(&self, key: &str) -> usize {
        let mut hash: usize = 0;
        // 使用简单的字符串哈希函数
        for &byte in key.as_bytes() {
            hash = hash.wrapping_mul(31).wrapping_add(byte as usize);
        }
        hash % self.capacity
    }

    // 插入键值对
    fn insert(&mut self, key: &'a str) {
        let hash = self.hash(&key);

        // 检查key是否已存在
        let mut current = &self.buckets[hash];
        while let Some(entry) = current {
            if entry.key == key {
                return; // 键已存在
            }
            current = &entry.next;
        }

        // 插入新节点
        let new_entry = Box::new(Entry {
            key,
            next: self.buckets[hash].take(),
        });

        self.buckets[hash] = Some(new_entry);
        self.size += 1;
    }
}